Python recursive algorithm

visit shbcf.ru